home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JSplitPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  7.4 KB  |  400 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.LayoutManager;
  6. import java.io.IOException;
  7. import java.io.ObjectOutputStream;
  8. import javax.accessibility.Accessible;
  9. import javax.accessibility.AccessibleContext;
  10. import javax.swing.plaf.SplitPaneUI;
  11.  
  12. public class JSplitPane extends JComponent implements Accessible {
  13.    private static final String uiClassID = "SplitPaneUI";
  14.    public static final int VERTICAL_SPLIT = 0;
  15.    public static final int HORIZONTAL_SPLIT = 1;
  16.    public static final String LEFT = "left";
  17.    public static final String RIGHT = "right";
  18.    public static final String TOP = "top";
  19.    public static final String BOTTOM = "bottom";
  20.    public static final String DIVIDER = "divider";
  21.    public static final String ORIENTATION_PROPERTY = "orientation";
  22.    public static final String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
  23.    public static final String DIVIDER_SIZE_PROPERTY = "dividerSize";
  24.    public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";
  25.    public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";
  26.    public static final String DIVIDER_LOCATION_PROPERTY = "dividerLocation";
  27.    public static final String RESIZE_WEIGHT_PROPERTY = "resizeWeight";
  28.    protected int orientation;
  29.    protected boolean continuousLayout;
  30.    protected Component leftComponent;
  31.    protected Component rightComponent;
  32.    protected int dividerSize;
  33.    private boolean dividerSizeSet;
  34.    protected boolean oneTouchExpandable;
  35.    private boolean oneTouchExpandableSet;
  36.    protected int lastDividerLocation;
  37.    private double resizeWeight;
  38.    private int dividerLocation;
  39.  
  40.    public JSplitPane() {
  41.       this(1, false, new JButton(UIManager.getString("SplitPane.leftButtonText")), new JButton(UIManager.getString("SplitPane.rightButtonText")));
  42.    }
  43.  
  44.    public JSplitPane(int var1) {
  45.       this(var1, false);
  46.    }
  47.  
  48.    public JSplitPane(int var1, boolean var2) {
  49.       this(var1, var2, (Component)null, (Component)null);
  50.    }
  51.  
  52.    public JSplitPane(int var1, Component var2, Component var3) {
  53.       this(var1, false, var2, var3);
  54.    }
  55.  
  56.    public JSplitPane(int var1, boolean var2, Component var3, Component var4) {
  57.       this.dividerSizeSet = false;
  58.       this.dividerLocation = -1;
  59.       this.setLayout((LayoutManager)null);
  60.       this.setUIProperty("opaque", Boolean.TRUE);
  61.       this.orientation = var1;
  62.       if (this.orientation != 1 && this.orientation != 0) {
  63.          throw new IllegalArgumentException("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");
  64.       } else {
  65.          this.continuousLayout = var2;
  66.          if (var3 != null) {
  67.             this.setLeftComponent(var3);
  68.          }
  69.  
  70.          if (var4 != null) {
  71.             this.setRightComponent(var4);
  72.          }
  73.  
  74.          this.updateUI();
  75.       }
  76.    }
  77.  
  78.    public void setUI(SplitPaneUI var1) {
  79.       if ((SplitPaneUI)this.ui != var1) {
  80.          super.setUI(var1);
  81.          this.revalidate();
  82.       }
  83.  
  84.    }
  85.  
  86.    public SplitPaneUI getUI() {
  87.       return (SplitPaneUI)this.ui;
  88.    }
  89.  
  90.    public void updateUI() {
  91.       this.setUI((SplitPaneUI)UIManager.getUI(this));
  92.       this.revalidate();
  93.    }
  94.  
  95.    public String getUIClassID() {
  96.       return "SplitPaneUI";
  97.    }
  98.  
  99.    public void setDividerSize(int var1) {
  100.       int var2 = this.dividerSize;
  101.       this.dividerSizeSet = true;
  102.       if (var2 != var1) {
  103.          this.dividerSize = var1;
  104.          this.firePropertyChange("dividerSize", var2, var1);
  105.       }
  106.  
  107.    }
  108.  
  109.    public int getDividerSize() {
  110.       return this.dividerSize;
  111.    }
  112.  
  113.    public void setLeftComponent(Component var1) {
  114.       if (var1 == null) {
  115.          if (this.leftComponent != null) {
  116.             this.remove(this.leftComponent);
  117.             this.leftComponent = null;
  118.          }
  119.       } else {
  120.          this.add(var1, "left");
  121.       }
  122.  
  123.    }
  124.  
  125.    public Component getLeftComponent() {
  126.       return this.leftComponent;
  127.    }
  128.  
  129.    public void setTopComponent(Component var1) {
  130.       this.setLeftComponent(var1);
  131.    }
  132.  
  133.    public Component getTopComponent() {
  134.       return this.leftComponent;
  135.    }
  136.  
  137.    public void setRightComponent(Component var1) {
  138.       if (var1 == null) {
  139.          if (this.rightComponent != null) {
  140.             this.remove(this.rightComponent);
  141.             this.rightComponent = null;
  142.          }
  143.       } else {
  144.          this.add(var1, "right");
  145.       }
  146.  
  147.    }
  148.  
  149.    public Component getRightComponent() {
  150.       return this.rightComponent;
  151.    }
  152.  
  153.    public void setBottomComponent(Component var1) {
  154.       this.setRightComponent(var1);
  155.    }
  156.  
  157.    public Component getBottomComponent() {
  158.       return this.rightComponent;
  159.    }
  160.  
  161.    public void setOneTouchExpandable(boolean var1) {
  162.       boolean var2 = this.oneTouchExpandable;
  163.       this.oneTouchExpandable = var1;
  164.       this.oneTouchExpandableSet = true;
  165.       this.firePropertyChange("oneTouchExpandable", var2, var1);
  166.       this.repaint();
  167.    }
  168.  
  169.    public boolean isOneTouchExpandable() {
  170.       return this.oneTouchExpandable;
  171.    }
  172.  
  173.    public void setLastDividerLocation(int var1) {
  174.       int var2 = this.lastDividerLocation;
  175.       this.lastDividerLocation = var1;
  176.       this.firePropertyChange("lastDividerLocation", var2, var1);
  177.    }
  178.  
  179.    public int getLastDividerLocation() {
  180.       return this.lastDividerLocation;
  181.    }
  182.  
  183.    public void setOrientation(int var1) {
  184.       if (var1 != 0 && var1 != 1) {
  185.          throw new IllegalArgumentException("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");
  186.       } else {
  187.          int var2 = this.orientation;
  188.          this.orientation = var1;
  189.          this.firePropertyChange("orientation", var2, var1);
  190.       }
  191.    }
  192.  
  193.    public int getOrientation() {
  194.       return this.orientation;
  195.    }
  196.  
  197.    public void setContinuousLayout(boolean var1) {
  198.       boolean var2 = this.continuousLayout;
  199.       this.continuousLayout = var1;
  200.       this.firePropertyChange("continuousLayout", var2, var1);
  201.    }
  202.  
  203.    public boolean isContinuousLayout() {
  204.       return this.continuousLayout;
  205.    }
  206.  
  207.    public void setResizeWeight(double var1) {
  208.       if (!(var1 < (double)0.0F) && !(var1 > (double)1.0F)) {
  209.          double var3 = this.resizeWeight;
  210.          this.resizeWeight = var1;
  211.          this.firePropertyChange("resizeWeight", var3, var1);
  212.       } else {
  213.          throw new IllegalArgumentException("JSplitPane weight must be between 0 and 1");
  214.       }
  215.    }
  216.  
  217.    public double getResizeWeight() {
  218.       return this.resizeWeight;
  219.    }
  220.  
  221.    public void resetToPreferredSizes() {
  222.       SplitPaneUI var1 = this.getUI();
  223.       if (var1 != null) {
  224.          var1.resetToPreferredSizes(this);
  225.       }
  226.  
  227.    }
  228.  
  229.    public void setDividerLocation(double var1) {
  230.       if (!(var1 < (double)0.0F) && !(var1 > (double)1.0F)) {
  231.          if (this.getOrientation() == 0) {
  232.             this.setDividerLocation((int)((double)(this.getHeight() - this.getDividerSize()) * var1));
  233.          } else {
  234.             this.setDividerLocation((int)((double)(this.getWidth() - this.getDividerSize()) * var1));
  235.          }
  236.  
  237.       } else {
  238.          throw new IllegalArgumentException("proportional location must be between 0.0 and 1.0.");
  239.       }
  240.    }
  241.  
  242.    public void setDividerLocation(int var1) {
  243.       int var2 = this.dividerLocation;
  244.       this.dividerLocation = var1;
  245.       SplitPaneUI var3 = this.getUI();
  246.       if (var3 != null) {
  247.          var3.setDividerLocation(this, var1);
  248.       }
  249.  
  250.       this.firePropertyChange("dividerLocation", var2, var1);
  251.       this.setLastDividerLocation(var2);
  252.    }
  253.  
  254.    public int getDividerLocation() {
  255.       return this.dividerLocation;
  256.    }
  257.  
  258.    public int getMinimumDividerLocation() {
  259.       SplitPaneUI var1 = this.getUI();
  260.       return var1 != null ? var1.getMinimumDividerLocation(this) : -1;
  261.    }
  262.  
  263.    public int getMaximumDividerLocation() {
  264.       SplitPaneUI var1 = this.getUI();
  265.       return var1 != null ? var1.getMaximumDividerLocation(this) : -1;
  266.    }
  267.  
  268.    public void remove(Component var1) {
  269.       if (var1 == this.leftComponent) {
  270.          this.leftComponent = null;
  271.       } else if (var1 == this.rightComponent) {
  272.          this.rightComponent = null;
  273.       }
  274.  
  275.       super.remove(var1);
  276.       this.revalidate();
  277.       this.repaint();
  278.    }
  279.  
  280.    public void remove(int var1) {
  281.       Component var2 = this.getComponent(var1);
  282.       if (var2 == this.leftComponent) {
  283.          this.leftComponent = null;
  284.       } else if (var2 == this.rightComponent) {
  285.          this.rightComponent = null;
  286.       }
  287.  
  288.       super.remove(var1);
  289.       this.revalidate();
  290.       this.repaint();
  291.    }
  292.  
  293.    public void removeAll() {
  294.       this.leftComponent = this.rightComponent = null;
  295.       super.removeAll();
  296.       this.revalidate();
  297.       this.repaint();
  298.    }
  299.  
  300.    public boolean isValidateRoot() {
  301.       return true;
  302.    }
  303.  
  304.    protected void addImpl(Component var1, Object var2, int var3) {
  305.       if (var2 != null && !(var2 instanceof String)) {
  306.          throw new IllegalArgumentException("cannot add to layout: constraint must be a string (or null)");
  307.       } else {
  308.          if (var2 == null) {
  309.             if (this.getLeftComponent() == null) {
  310.                var2 = "left";
  311.             } else if (this.getRightComponent() == null) {
  312.                var2 = "right";
  313.             }
  314.          }
  315.  
  316.          if (var2 == null || !var2.equals("left") && !var2.equals("top")) {
  317.             if (var2 != null && (var2.equals("right") || var2.equals("bottom"))) {
  318.                Component var5 = this.getRightComponent();
  319.                if (var5 != null) {
  320.                   this.remove(var5);
  321.                }
  322.  
  323.                this.rightComponent = var1;
  324.                var3 = -1;
  325.             } else if (var2 != null && var2.equals("divider")) {
  326.                var3 = -1;
  327.             }
  328.          } else {
  329.             Component var4 = this.getLeftComponent();
  330.             if (var4 != null) {
  331.                this.remove(var4);
  332.             }
  333.  
  334.             this.leftComponent = var1;
  335.             var3 = -1;
  336.          }
  337.  
  338.          super.addImpl(var1, var2, var3);
  339.          this.revalidate();
  340.          this.repaint();
  341.       }
  342.    }
  343.  
  344.    protected void paintChildren(Graphics var1) {
  345.       super.paintChildren(var1);
  346.       SplitPaneUI var2 = this.getUI();
  347.       if (var2 != null) {
  348.          Graphics var3 = var1.create();
  349.          var2.finishedPaintingChildren(this, var3);
  350.          var3.dispose();
  351.       }
  352.  
  353.    }
  354.  
  355.    private void writeObject(ObjectOutputStream var1) throws IOException {
  356.       var1.defaultWriteObject();
  357.       if (this.getUIClassID().equals("SplitPaneUI")) {
  358.          byte var2 = JComponent.getWriteObjCounter(this);
  359.          --var2;
  360.          JComponent.setWriteObjCounter(this, var2);
  361.          if (var2 == 0 && this.ui != null) {
  362.             this.ui.installUI(this);
  363.          }
  364.       }
  365.  
  366.    }
  367.  
  368.    void setUIProperty(String var1, Object var2) {
  369.       if (var1 == "dividerSize") {
  370.          if (!this.dividerSizeSet) {
  371.             this.setDividerSize(((Number)var2).intValue());
  372.             this.dividerSizeSet = false;
  373.          }
  374.       } else if (var1 == "oneTouchExpandable") {
  375.          if (!this.oneTouchExpandableSet) {
  376.             this.setOneTouchExpandable((Boolean)var2);
  377.             this.oneTouchExpandableSet = false;
  378.          }
  379.       } else {
  380.          super.setUIProperty(var1, var2);
  381.       }
  382.  
  383.    }
  384.  
  385.    protected String paramString() {
  386.       String var1 = this.orientation == 1 ? "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT";
  387.       String var2 = this.continuousLayout ? "true" : "false";
  388.       String var3 = this.oneTouchExpandable ? "true" : "false";
  389.       return super.paramString() + ",continuousLayout=" + var2 + ",dividerSize=" + this.dividerSize + ",lastDividerLocation=" + this.lastDividerLocation + ",oneTouchExpandable=" + var3 + ",orientation=" + var1;
  390.    }
  391.  
  392.    public AccessibleContext getAccessibleContext() {
  393.       if (this.accessibleContext == null) {
  394.          this.accessibleContext = new AccessibleJSplitPane(this);
  395.       }
  396.  
  397.       return this.accessibleContext;
  398.    }
  399. }
  400.